import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';
import '../route.dart';
import 'dart:convert';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String message = '<unknown>';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("首页"),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.arrow_right),
            onPressed: () => intentTo(context),
          ),
        ],
      ),
    );
  }

  void intentTo(BuildContext context) {
    final jsonStr = jsonEncode(Utf8Encoder().convert("来自第一个界面"));
    RouteRule.router.navigateTo(
      context, '${RouteRule.profile}?msg=$jsonStr',
      transition: TransitionType.inFromRight
    ).then((result) {
      if (result != null) {
        message = result;
      }
    });
  }
}